import { AxiosRequestConfig, AxiosResponse } from "axios";
import api from "../utils/request.ts";
import type { User, PaginationResponse, GetListParams } from "./types/user";

export const userApi = {
  /**
   * 获取用户详情
   * @param userId 用户ID
   * @param config 自定义配置
   */
  getById: (userId: number, config?: AxiosRequestConfig) => {
    return api.get<User>(`/users/${userId}`, config);
  },
  createNotice: (params: any, config?: AxiosRequestConfig) => {
    return api.post<User>(`announce/create_announce`, params, config);
  },
  /**
   * 分页查询用户
   * @param params 查询参数
   */
  getList: (params: { page: number; pageSize: number; name?: string }) => {
    return api.get<PaginationResponse<User>>("/users", { params });
  },

  /**
   * 创建用户
   * @param data 用户数据
   */
  create: (data: Omit<User, "id">) => {
    return api.post<{ id: number }>("/users", data);
  },

  //新用户综合数据

  getNewList: (params: GetListParams): Promise<AxiosResponse> => {
    return api.post("analyse_data/newer_comprehensive_view", params);
  },
};
